/*=+--+=#=+--     Unmanned Aerial System Management Software      --+=#=+--+=#*\
|          Copyright (C) 2011 Regents of the University of Colorado.           |
|                             All Rights Reserved.                             |

     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License version 2 as
     published by the Free Software Foundation.

     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.

     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>.

            Jack Elston                       Cory Dixon                        
|           elstonj@colorado.edu              dixonc@colorado.edu              |
|                                                                              |
\*=+--+=#=+--                 --+=#=+--+=#=+--                    --+=#=+--+=#*/

/***********************************************************************
 *
 * FILENAME:
 * systemInfo.h
 *
 * PURPOSE:
 *   Collects system info from computer
 *
 * CREATED:
 * 11/2000 by Cory Dixon
 *
 * LAST MODIFIED:
 * $Author: dixonc $
 * $Date: 2005/11/02 20:27:20 $
 * $Revision: 1.4 $
 *
 ***********************************************************************/

#ifndef _SYSTEMINFO_H
#define _SYSTEMINFO_H

#include <sys/statfs.h>

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

struct statinfo {
	unsigned long cpu_user;    /* user processor time */
	unsigned long cpu_nice;    /* niced processor time */
	unsigned long cpu_system;  /* system processor time */
	unsigned long cpu_idle;    /* idle processor time */
	unsigned long cpu_iowait;  /* I/O wait processor time */
};

struct meminfo {
	unsigned long mem_total;  // bytes
	unsigned long mem_free;   // bytes
	unsigned long swap_total;  // bytes
	unsigned long swap_free;   // bytes
};

#define STAT_BUF_LEN 2048

int getStat(struct statinfo *stats);
int getMem(struct meminfo *memPtr);
int getDisk (struct statfs *disk);

float calcCPU(struct statinfo *now, struct statinfo *last);
float calcMem(struct meminfo *memPtr);
float calcSwap(struct meminfo *memPtr);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif // _SYSTEMINFO_H
